/*
 * @Author: lcy
 * @Date: 2021-12-14 11:57:09
 * @Last Modified by: lcy
 * @Last Modified time: 2021-12-14 11:58:28
 */
//index.ts

import { InjectionKey } from "@vue/runtime-core"
import { createStore, Store, useStore as baseUseStore } from "vuex"


// 导入用户模块
import { store as user, UserState } from "./moudles/user/index"

//定义RootState接口，将所有模块类型放入
export interface RootState {
  count: number
  user: UserState
}
export const key: InjectionKey<Store<RootState>> = Symbol()

export const store: Store<RootState> = createStore({
  state: <RootState>{
    count: 28,
  },
  modules: { user },
})

export function useStore() {
  return baseUseStore(key)
}
